Skip to content


tag  jupyter  tips  ai  deep learning  beginner  regression  reinforcement learning  q learning  gym  gymnasium  ardupilot  None  ros2  dds  micro ros  xrce  sitl  plugin  SITL  debug  rangefinder  pymavlink  mavros  gazebo  distance sensor  system_time  timesync  cmake  gtest  ctest  101  cpp  c++  format  fmt  multithreading  spdlog  cyclonedds  eprosima  fastdds  simulation  config  ignition  bridge  sdf  ign-transport  camera  sensors  lidar  aptly  apt  repository  repo  local  mirror  encryption  pgp  docker  compose  tutorial  networking  network  nvidia  python  app  devcontainer  gui  multi-stage  stage  git  bundle  submodules  github  hooks  pre-commit  lxd  container  lxc  x11  profile  vscode  marpit  presentation  marp  markdown  mermaid  mkdocs  video  ffmpeg  gstreamer  cheat-sheet  sdp  v4l2loopback  gi  kml  geo  gis  spatial  gdal  ogr  raster  vector  snippets  cheat Sheet  asyncio  future  click  cli  deb  debian  package  setup  stdeb  project  numpy  template  black  isort  templates  cookiecutter  docs  project document  docstrings  flake8  linter  git-hook  mypy  unittest  pytest  pylint  from a-z  mock  iterator  generator  yaml  yml  logging  tuple  namedtuple  typing  annotation  typever  pyzmq  zmq  msgpack  action  namespace  remap  control2  ros2_control  effort  velocity  gdb  qos  plugins  msg  node  zero-copy  shm  algorithm  calibration  diff  pid  dev  colcon  colcon_cd  settings  behavior  py_trees  bt  behavior_trees  blackboard  plot  visualization  debugging  diagnostic  DiagnosticTask  diagnostics  tutorials  gst  math  apm  rat_runtime_monitor  bag  rosbag  rosbags  tools  ros  web  rosbridge  vue  binding  discovery  gazebo-classic  launch  spawn  model  cook  gps  imu  ray  gazebo_ros_ray_sensor  ultrsonic  range  ultrasonic  gazebo classic  wrench  odom  ign  gz  xacro  ros_ign  diff_drive  odometry  joint_state  argument  OpaqueFunction  DeclareLaunchArgument  LaunchConfiguration  tmux  nav  slam  test  rclpy  goal abort  cancel goal  action client  action server  custom messages  executor  MultiThreadedExecutor  SingleThreadedExecutor  param  dynamic-reconfigure  service  client  setup.py  package.xml  parameter  parameters  custom  msgs  executers  pub  sub  rqt  rviz  rviz2  pose  marker  tf2  local_setup  rosdep  package manager  project settings  vcstool  urdf  robot_state_publisher  urdf_to_graphiz  joint  link  zenoh  tags  hands on  webinar  cross-compiler  nano  rpi  texture  joints  tmuxp  loop device  rootfs  embedded  zah  linux  rm  ubuntu  sudo  sudoers  nopasswd  visudo  udev  key  gpg  sign  ip  ss  netstat  snap  deploy  ssh  systemd  socat  serial  udp  tc  mtu  select  path planning  trajectory  speed  robotics  kalman_filter  kalman  filter  control  code  extensions  json  schema  dev container  docker compose  yocto  poky  qemu  projects  courses to follow  drone  quad  uav  design  vrx  buoyancy 

gazebo ignition hello world


First try#

Run gazebo with empty world from install worlds

install worlds

/usr/share/ignition/ignition-gazebo6

ign gazebo empty.sdf -v 4
# -v 4 => verbose

ign cli#

  • ign cli hello
  • run custom world
  • control gui options
  • spawn and delete entities from cli

ign command#

ign --help
The 'ign' command provides a command line interface to the ignition tools.

  ign <command> [options]

List of available commands :

  help:          Print this help text.
  ...
  gazebo:        Run and manage Gazebo.
  msg:           Print information about messages.
  ...
  topic:         Print information about topics.
  service:       Print information about services.
  ...

ign gazebo command#

ign gazebo --help

  -r                           Run simulation on start.                         

  -v [ --verbose ] [arg]       Adjust the level of console output (0~4).        

  --gui-config [arg]           Ignition GUI configuration file to load.         

Environment variables#

Variable Description
IGN_GAZEBO_RESOURCE_PATH Colon separated paths used to locate resources such as worlds and models.
IGN_GAZEBO_SYSTEM_PLUGIN_PATH Colon separated paths used to locate system plugins.
for more check ign gazebo –help

Custom world.sdf#

  • load minimal world
  • control gui layout
  • spawn / delete model from cli

Set ignition resource path

export IGN_GAZEBO_RESOURCE_PATH=/home/user/projects/ign_tutorial/
my_empty.sdf
<sdf version="1.6">
    <world name="empty">
      <physics name="1ms" type="ignored">
        <max_step_size>0.001</max_step_size>
        <real_time_factor>1.0</real_time_factor>
      </physics>
      <gui>
        <plugin filename="GzScene3D" name="3D View">
            <ignition-gui>
            <title>3D View</title>
            <property type="bool" key="showTitleBar">false</property>
            <property type="string" key="state">docked</property>
            </ignition-gui>

            <engine>ogre2</engine>
            <scene>scene</scene>
            <ambient_light>0.4 0.4 0.4</ambient_light>
            <background_color>0.8 0.8 0.8</background_color>
        </plugin>

      </gui>
      <plugin
        filename="ignition-gazebo-physics-system"
        name="ignition::gazebo::systems::Physics">
      </plugin>
      <plugin
        filename="ignition-gazebo-user-commands-system"
        name="ignition::gazebo::systems::UserCommands">
      </plugin>
      <plugin
        filename="ignition-gazebo-scene-broadcaster-system"
        name="ignition::gazebo::systems::SceneBroadcaster">
      </plugin>
      <plugin
        filename="ignition-gazebo-contact-system"
        name="ignition::gazebo::systems::Contact">
      </plugin>

      <light type="directional" name="sun">
        <cast_shadows>true</cast_shadows>
        <pose>0 0 10 0 0 0</pose>
        <diffuse>0.8 0.8 0.8 1</diffuse>
        <specular>0.2 0.2 0.2 1</specular>
        <attenuation>
          <range>1000</range>
          <constant>0.9</constant>
          <linear>0.01</linear>
          <quadratic>0.001</quadratic>
        </attenuation>
        <direction>-0.5 0.1 -0.9</direction>
      </light>

      <model name="ground_plane">
        <static>true</static>
        <link name="link">
          <collision name="collision">
            <geometry>
              <plane>
                <normal>0 0 1</normal>
                <size>100 100</size>
              </plane>
            </geometry>
          </collision>
          <visual name="visual">
            <geometry>
              <plane>
                <normal>0 0 1</normal>
                <size>100 100</size>
              </plane>
            </geometry>
            <material>
              <ambient>0.8 0.8 0.8 1</ambient>
              <diffuse>0.8 0.8 0.8 1</diffuse>
              <specular>0.8 0.8 0.8 1</specular>
            </material>
          </visual>
        </link>
      </model>

    </world>
  </sdf>
  • Everything control by plugin

Spawn and remove models#

user-commands-system#

Allow user control from cli

<plugin
    filename="ignition-gazebo-user-commands-system"
    name="ignition::gazebo::systems::UserCommands">
</plugin>

ign service / msg command#

  • # list services
    ign service --list
    ...
    /world/empty/create
    ...
    /world/empty/remove
    ...
    
    
    # more info about the service
    ign service --info --service /world/empty/remove
    # result
    Service providers [Address, Request Message Type, Response Message Type]:
      tcp://172.18.0.1:45365, ignition.msgs.Entity, ignition.msgs.Boolean
    
    # Service has two type of message
    # request: ignition.msgs.Entity
    # response: ignition.msgs.Boolean
    
    # message fields
    ## serach for boolean msg
    ign msg --list | grep Boolean
    ign_msgs.Boolean
    
    # show msg fields with --info argument
    user@lap2:~/projects/blog$ ign msg --info ign_msgs.Boolean
    Name: ignition.msgs.Boolean
    File: ignition/msgs/boolean.proto
    
    message Boolean {
      .ignition.msgs.Header header = 1;
      bool data = 2;
    }
    

Spawn SDF#

using ign service to Spawn and remove entities

from SDF file
ign service -s /world/empty/create --reqtype ignition.msgs.EntityFactory --reptype ignition.msgs.Boolean --timeout 300 --req 'sdf_filename: "models/my_ball/model.sdf" pose: {position: {z: 5}} name: "new_name"'
from SDF string

Remove#

ign service -s /world/empty/remove \
--reqtype ignition.msgs.Entity \
--reptype ignition.msgs.Boolean \
--timeout 300 \
--req 'name: "new_name" type: MODEL'
models/my_ball/model.sdf
<sdf version="1.6">
    <model name="spawned_model">
        <link name="link">
            <visual name="visual">
                <geometry>
                    <sphere>
                        <radius>2.0</radius>
                    </sphere>
                </geometry>
            </visual>
            <collision name="visual">
                <geometry>
                    <sphere>
                        <radius>2.0</radius>
                    </sphere>
                </geometry>
            </collision>
        </link>
    </model>
</sdf>